home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Communications
/
General
/
LineShare Folder
/
Put Onto Productions Disks
/
LineShare Scripts
/
Fax Class2&ARA&Data
< prev
next >
Wrap
Text File
|
1994-04-28
|
8KB
|
431 lines
! Version 3.0.2
!
!$ Use this script with Class 2 fax software, ARA 1.0 or 2.0,
!$ and a BBS, E-mail or other communication server software
!
!$ A cable for hardware handshaking is required
^# Modem:
^2 Fax Software: = Enum("FaxSTF™"="0","4-Sight™"="1","Delrina"="2","Glenwarne sw/hsk"="3","Glenwarne hw/hsk"="4") "0"
^3 Error Correction: = Bool("Enabled"="AUTO","Disabled"="NORM") "NORM"
^4 Handshake wires: = Bool("CTS+DTR"="&D0","CTS only"="&D2") "&D2"
^5 Answer On: = Enum("Never"="0","1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
! ------------------------------------------
! Resetting the modem:
! ------------------------------------------
@Hangup
SetTries 2
Flush
HsReset 0,0,0,0,0,0
!
! Try to catch the "OK" answer, use the Escape seq and DTR transitions
! to enter the command mode
!
@Label 1
matchclr
matchstr 1 2 "OK\r\n"
write "ATH0V1Q0\r"
matchread 20
ChrDelay 1
Write "+++"
ChrDelay 0
DtrClear
SBreak
DtrSet
!
DecTries
IfTries 0 1
!
! OSErr -6019 "Modem error - the modem is not responding"
!
exit -6019
@Label 2
SetVar A "&F"
GetOption A "DFLT" 3
@Label 3
write "AT^A+FCLASS=0;+FAA=0\r"
Jsr 100
exit 0
@Label 6
Say "This script cannot be used with this modem"
ifOriginate 7
pause 1800
@Label 7
exit -6019
! ------------------------------------------
! Receiving incoming calls
! ------------------------------------------
@ANSWER
@Label 10
!
! Set the modem preferred speed first
SerReset 19200,0,8,1
Jsr 80
!
! Set the common options
Jsr 70
!
! Set the communication options:
! • Normal/AUTO Connection
! • HW flow control (for ARA, Fax should not use a handshake on receiving)
! • CONNECT <DCE speed> or CARRIER/CONNECT
!
GetOption A "HWHS" 6
GetOption B "^3" 6
GetOption C "LNRS" 6
Write "AT^A^B^C\r"
Jsr 100
!
! Set Fax parameters: LID, DCC,BOR
!
Write "AT+FCLASS=2;+FCR=1;+FAA=1\r"
Jsr 100
!
! Set FLID - sometimes it can fail
!
GetCommand A "Fax" "+FLID="
Write "AT^A\r"
MatchClr
MatchStr 1 11 "OK\r\n"
MatchRead 10
@Label 11
Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
Jsr 100
GetCommand A "Fax" "+FDCC="
Write "AT^A\r"
Jsr 100
GetCommand A "Fax" "+FBOR="
Write "AT^A\r"
Jsr 100
!
! It's for Rockwell ONLY! Set FCLASS to 0 again
GetOption A "RCWL" 12
Write "AT+FCLASS=0\r"
Jsr 100
@Label 12
!
! Get the Speaker and the Ring Num options
GetCommand B "Fax" "M"
GetCommand C "Fax" "L"
GetCommand D "Fax" "S0"
! SetVar A "S0=2"
! ifStr D 13 "S0=0"
! ifStr D 13 ""
! SetVar A "^D"
!@Label 13
SetVar A "S0=^5"
!
! Fetch the tube after <A> rings
Write "AT^A^B^C\r"
Jsr 100
!
! Everything is ready - let's sit and wait for a call
! We'll wait for 2 minutes, then reinitiate the modem
Note "Waiting for a Fax/ARA/Data call…"
Jsr 90
IfStr D 40 "FAX"
IfStr D 20 "DATA"
Jump 10
!
! Data connection has been established (we read "CONNECT")
! Put the "CONNECT" back to the buffer and attach the "Data" subPort
! if it was an incoming call, put the "RING" before the "CONNECT"
!
@Label 20
IfOpen "Data" 21
Jump 30
@Label 21
IfOpen "ARA" 22
Jump 35
@Label 22
Note "Waiting for an ARA frame"
MatchClr
MatchStr 1 23 "^$\r"
MatchStr 2 28 "\08\01\03\14\04\03\00\08\250\16\03"
MatchStr 3 29 "\01\27\02\29\01\02\01\06"
MatchRead 40
Jump 24
@Label 23
QueueInput "^$\r"
@Label 24
Note "Non-ARA call"
Jump 35
@Label 28
Note "ARA 1.0 call"
Jump 30
@Label 29
Note "ARA 2.0 call"
Jump 30
@Label 30
QueueInput "\r\nCARRIER ^B\r\n"
IfStr A 31 "NONE"
IfStr A 31 "None"
QueueInput "\r\nREL\r\n"
@Label 31
IfOriginate 32
QueueInput "\r\nRING\r\n"
@Label 32
Attach "ARA" (DTR)
@Label 35
GetSReg C "DATA" 4
QueueInput "\r^CCONNECT ^B\r^C"
ifOriginate 36
QueueInput "\r^CRING\r^C"
@Label 36
HsReset 0,1,0,0,0,1
Attach "Data" (DTR,Escape,Break)
!
! Fax connection has been established (we read "+FCON")
! Put the +FCON back to the buffer,
! if it was an incoming call, put the "RING" before the "+FCON"
! Attach the "Fax" subPort
!
@Label 40
QueueInput "\r\n+FCON"
ifOriginate 41
QueueInput "\r\nRING\r\n"
@Label 41
IfStr 2 42 "0"
IfStr 2 42 "3"
IfStr 2 42 "4"
Attach "Fax" (DTR,IdleLimit=30)
@Label 42
Attach "Fax" (DTR,Reset,IdleLimit=30)
! ------------------------------------------
! Originating a call through the "ARA" subport
! ------------------------------------------
@ORIGINATE "ARA"
SerReset 19200,0,8,1
Jsr 80
!
! Set the common options
Jsr 70
!
! Set the communication options:
! • Normal Connection
! • HW flow control
! • CONNECT <DCE speed> or CARRIER/CONNECT
!
GetOption A "HWHS" 6
GetOption B "^3" 6
GetOption C "LNRS" 6
Write "AT^A^B^C\r"
Jsr 100
!
! dial the number
Write "ATD^1\r"
!
! Wait for a modem response
Jsr 90
IfStr D 30 "DATA"
Write "\r"
Exit -6019
! ------------------------------------------
! Originating a call through the "DATA" subport
! ------------------------------------------
@ORIGINATE "Data" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
SerReset 19200,0,8,1
Jsr 80
!
! Set the common options
Jsr 70
!
! Set the communication options:
! • Normal Connection
! • HW flow control
! • CONNECT <DCE speed> or CARRIER/CONNECT
!
GetOption A "HWHS" 6
GetOption B "^3" 6
GetOption C "LNRS" 6
Write "AT^A^B^C\r"
Jsr 100
!
! dial the number
Write "ATD^1\r"
HsReset *
!
! Wait for a modem response
Jsr 90
IfStr D 35 "DATA"
Write "\r"
Exit -6019
! ------------------------------------------
! Originating a call through the "Fax" subPort
! ------------------------------------------
@ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
!
! Set the "Fax" speed
!
SerReset 19200,0,8,1
Jsr 80
!
! Set the common options
!
Jsr 70
!
! Now emit all commands that the application has sent to that port,
! except "V" and "+FCLASS"
!
EmitClear "V","+FCLASS"
Jsr 60
Write "AT+FCLASS=2\r"
Jsr 100
!
! setting the handshaking mode for faxing
ifStr 2 50 "3"
ifStr 2 51 "4"
HsReset *
Jump 53
@Label 50
HSReset 1,0,17,19,1,0
GetOption A "SWHS" 6
Jump 52
@Label 51
HSReset 0,1,0,0,0,0
GetOption A "HWHS" 6
@Label 52
Write "AT^A\r"
Jsr 100
@Label 53
!
! dialing the number
Write "ATD^1\r"
Jsr 90
IfStr D 40 "FAX"
Write "\r"
Exit -6019
!
! This section emits all modem commands sent from the client application
! For each set of commands the "OK" answer is awaited
!
@Label 60
EmitStart
@Label 61
EmitCommand 62
Jsr 100
Jump 61
@Label 62
return
!
! This section initiates the modem before ANSWER and ORIGINATEs:
! reset on Dtr drop + DCD valid
! Verbal responses mode, no echo
!
@Label 70
Write "AT^4&C1V1E0\r"
Jsr 100
return
!
! This section syncronize the modem after the serial port speed switching
!
@Label 80
ChrDelay 1
Write "AT\r"
ChrDelay 0
Jsr 100
return
!
! Error codes
@Label 81
exit -6020
@Label 82
exit -6022
@Label 83
exit -6021
@Label 84
exit -6023
!
! This subroutine waits for the modem response
! On exit, ^D contains the result code: "FAX" or "DATA"
! ^A contains the protocol used
! ^B contains the carrier speed
! If modem reports an error, the scripts exits with an error code
!
@Label 89
Note "Ring…"
Jump 91
@Label 90
SetVar A "NONE"
SetVar B ""
MatchClr
Matchstr 1 92 "CARRIER ^$\r\n"
Matchstr 2 93 "PROTOCOL: ^$\r\n"
Matchstr 3 94 "+FCON"
Matchstr 4 95 "CONNECT ^$/"
Matchstr 5 97 "CONNECT ^$\r\n"
Matchstr 6 89 "RING\r\n"
Matchstr 10 82 "BUSY\r\n"
MatchStr 11 83 "NO CARRIER\r\n"
MatchStr 12 84 "NO ANSWER\r\n"
MatchStr 13 81 "NO DIALTONE\r\n"
@Label 91
Matchread 1200
SetVar D "NONE"
return
@Label 92
SetVar B "^$"
Jump 91
@Label 93
SetVar A "^$"
Jump 91
!
! Fax connection was established
!
@Label 94
SetVar D "FAX"
return
! CONNECT xxxx/XXXX was detected
@Label 95
Jsr 98
MatchClr
MatchStr 1 96 "^$\r\n"
MatcRead 10
@Label 96
SetVar A "^$"
SetVar D "DATA"
return
! CONNECT xxx was detected
@Label 97
Jsr 98
SetVar D "DATA"
return
@Label 98
ifStr B 99 ""
return
@Label 99
SetVar B "^$"
return
!
! Processing the AT command:
! OK -> proceed
! ERROR or TimeOut ->exit -6019
! It can be called AFTER the "Write" command, since LineShare buffers input
!
@Label 100
MatchClr
MatchStr 1 102 "OK\r\n"
MatchStr 2 101 "ERROR\r\n"
MatchRead 20
@Label 101
Exit -6019
@Label 102
return